<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../../vars.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="ECharts">
    <title>WAS SERVER重要指标监控</title>
    <link href="${contextPath}/page/common/css/bootstrap.css" rel="stylesheet">
    <link href="${contextPath}/page/common/css/echartsHome.css" rel="stylesheet">
    <script src="${contextPath}/page/common/js/chart/echarts.js"></script>
    <script src="${contextPath}/page/common/js/chart/codemirror.js"></script>
    <script language="JavaScript" src="${contextPath}/page/common/js/calendar/calendar.js"></script>
    <style type="text/css">
        #loading-mask{
            position:absolute;
            left:0;
            top:0;
            width:100%;
            height:100%;
            z-index:20000;
            background-color:#ececec;
        }
        #loading{
            position:absolute;
            left:45%;
            top:40%;
            padding:2px;
            z-index:20001;
            height:auto;
        }
        #loading .loading-indicator{
            background:#ececec;
            color:#444;
            font:bold 20px tahoma,arial,helvetica;
            margin:-90px 20px 20px -160px;
            height:auto;
        }
        #loading-msg {
            font: normal 18px arial,tahoma,sans-serif;
        }
    </style>

</head>
<body>
<table style="width: 100%;margin-top: -40px;">
    <tr>
        <td>
            <div style="font-size: 14px;color: red;width:300px; float:right; text-align:right; line-height:20px;">
                选择时间：<input type="text" name="endDate" id="calendar" style="width:135px" value="${currentDate}" onchange="loadMonitor();"/>
            </div>
        </td>
    </tr>
    <tr>
        <td>
            <div id="main" style="height:330px;margin:0px 15px 0px 15px;"></div>
        </td>
    </tr>
    <tr>
        <td>
            <div id="sub" style="height:320px;margin:20px 15px 0px 15px;"></div>
        </td>
    </tr>
</table>
<div id='loading-mask' style="display: block;"></div>
<div id="loading" style="display: block;">
    <div class="loading-indicator">
        <img src="${contextPath}/page/common/images/lodding.gif"  style=""/>
        <!--<br/><span id="loading-msg">Loading ...</span>-->
    </div>
</div>
<script type="text/javascript">
    function loadMonitor(){
        var currentDate = document.getElementById("calendar").value;
        window.location.href="${contextPath}/MonitorManage/monitorIn?serverName=${server}&type=${type}&currentDate="+currentDate;
    }

    document.onreadystatechange = subSomething;//当页面加载状态改变的时候执行这个方法.
    function subSomething() {
        if(document.readyState=="complete"){
            document.getElementById("loading-mask").style.display="none";
            document.getElementById("loading").style.display="none";
        }
    }
    // 路径配置
    require.config({
        paths: {
            echarts: 'http://echarts.baidu.com/build/dist'
        }
    });

    // 使用
    require(
            [
                'echarts',
                'echarts/chart/line', // 使用柱状图就加载bar模块，按需加载
                'echarts/chart/bar' // 使用柱状图就加载bar模块，按需加载
            ],
            function (ec) {
                // 基于准备好的dom，初始化echarts图表
                var myChart = ec.init(document.getElementById('main'));

                option = {
                    title : {
                        text: 'JVM 使用情况',
                        subtext: '数据来自${server}',
                        x: 'center'
                    },
                    tooltip : {
                        trigger: 'axis',
                        formatter: function(params) {
                            return '<div style="font-size:12px;font-family: Georgia,Serif;">${currentDate} '+params[0].name + '<br/>'
                                    + params[0].seriesName + ' : ' + params[0].value + '<br/>'
                                    + params[1].seriesName + ' : ' + params[1].value + '<br/>'
                                    + params[2].seriesName + ' : ' + params[2].value + '<br/>'
                                    + params[3].seriesName + ' : ' + params[3].value + '</div>';
                        }
                    },
                    legend: {
                        data:[${monitorJvm}],
                        x: 'left'
                    },
                    toolbox: {
                        show : true,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType : {show: true, type: ['line', 'bar']},
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    dataZoom : {
                        show : true,
                        realtime : true,
                        start : 50,
                        end : 70
                    },
                    xAxis : [
                        {
                            type : 'category',
                            boundaryGap : false,
                            axisLine: {onZero: false},
                            data : [${monitorInfo.currentJvmDate}]
                        }
                    ],
                    yAxis : [
                        {
                            name : 'HeapSize',
                            type : 'value',
                        },
                        {
                            name : 'UsedMemory',
                            type : 'value',
                        },
                        {
                            name : 'FreeMemory',
                            type : 'value',
                        },
                        {
                            name : 'ProcessCpuUsage',
                            type : 'value',
                        }
                    ],
                    series : [
                        {
                            name:'HeapSize',
                            type:'line',
                            itemStyle: {normal: {areaStyle: {type: 'default'}}},
                            data:[${monitorInfo.heapSize}]
                        },
                        {
                            name:'UsedMemory',
                            type:'line',

                            itemStyle: {normal: {areaStyle: {type: 'default'}}},
                            data:[${monitorInfo.usedMemory}]
                        },{
                            name:'FreeMemory',
                            type:'line',
                            itemStyle: {normal: {areaStyle: {type: 'default'}}},
                            data:[${monitorInfo.freeMemory}]
                        },
                        {
                            name:'ProcessCpuUsage',
                            type:'line',

                            itemStyle: {normal: {areaStyle: {type: 'default'}}},
                            data:[${monitorInfo.processCpuUsage}]
                        }
                    ]
                };

                // 为echarts对象加载数据
                myChart.setOption(option);
            }
    );



    // 使用
    require(
            [
                'echarts',
                'echarts/chart/line', // 使用柱状图就加载bar模块，按需加载
                'echarts/chart/bar' // 使用柱状图就加载bar模块，按需加载
            ],
            function (ec) {
                // 基于准备好的dom，初始化echarts图表
                var myChart = ec.init(document.getElementById('sub'));

                option = {
                    title : {
                        text: 'ORB线程信息情况',
                        subtext: '数据来自${server}',
                        x: 'center'
                    },
                    tooltip : {
                        trigger: 'axis',
                        formatter: function(params) {
                            return '<div style="font-size:12px;font-family: Georgia,Serif;">${currentDate}'+params[0].name + '<br/>'
                                    + params[1].seriesName + ' : ' + params[1].value + '<br/>'
                                    + params[2].seriesName + ' : ' + params[2].value + '<br/>'
                                    + params[3].seriesName + ' : ' + params[3].value + '</div>';
                        }
                    },
                    legend: {
                        data:[${monitorThread}],
                        x: 'left'
                    },
                    toolbox: {
                        show : true,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType : {show: true, type: ['line', 'bar']},
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    dataZoom : {
                        show : true,
                        realtime : true,
                        start : 50,
                        end : 70
                    },
                    xAxis : [
                        {
                            type : 'category',
                            boundaryGap : false,
                            axisLine: {onZero: false},
                            data : [${monitorInfo.currentJvmDate}]
                        }
                    ],
                    yAxis : [
                        {
                            name : 'ActiveCount',
                            type : 'value',
                        },
                        {
                            name : 'CreateCount',
                            type : 'value',
                        },{
                            name : 'DestroyCount',
                            type : 'value',
                        },
                        {
                            name : 'PoolSize',
                            type : 'value',
                        }
                    ],
                    series : [
                        {
                            name:'ActiveCount',
                            type:'line',
                            itemStyle: {normal: {areaStyle: {type: 'default'}}},
                            data:[${monitorInfo.activeCount}]
                        },
                        {
                            name:'CreateCount',
                            type:'line',

                            itemStyle: {normal: {areaStyle: {type: 'default'}}},
                            data:[${monitorInfo.createCount}]
                        },{
                            name:'DestroyCount',
                            type:'line',
                            itemStyle: {normal: {areaStyle: {type: 'default'}}},
                            data:[${monitorInfo.destroyCount}]
                        },
                        {
                            name:'PoolSize',
                            type:'line',
                            itemStyle: {normal: {areaStyle: {type: 'default'}}},
                            data:[${monitorInfo.poolSize}]
                        }
                    ]
                };

                // 为echarts对象加载数据
                myChart.setOption(option);
            }
    );

</script>


<script src="${contextPath}/page/common/js/chart/jquery.min.js"></script>
<%@ include file="chartline.jsp" %>
</body>
</html>
